#ifndef ROOM_COMMAND_IN_H_
#define ROOM_COMMAND_IN_H_
#include "command.h"

#pragma pack(1)
namespace Cmd
{
        namespace Room
        {
                //  cmd declaration
                enum {
                        CMDIN_LOGIN	        = 0x0001,	// 其他服务器连接RoomServer验证
                        CMDIN_PKG               = 0x0002,	// 包裹指令
                        CMDIN_FORWARD           = 0x0003,	// 与RoomGatewayServer交互的指令
                        CMDIN_FUNC              = 0x0004,	// 内部功能指令
                };
                enum { //CMDIN_LOGIN
                        SCMDIN_LOGIN                            = 0x0001,
                        SCMDIN_LOGIN_RESPONCE                   = 0x0002,
                };
                enum { //CMDIN_PKG
                        SCMDIN_PKG_USER_CMD                     = 0x0001,	// 包裹用户指令
                        SCMDIN_PKG_INNER_CMD                    = 0x0002,	// 包裹服务器内部指令 Cmd::Room空间
                        SCMDIN_PKG_USER_CMD_BROAD               = 0x0003,	// 包裹通过网关分发的指令
                };
                enum { //CMDIN_FORWARD
                        //RoomServer -> RoomGatewayServer 
                        SCMDIN_FORWARD_TO_SERVER_BY_SERVERID    = 0x0000,	// 转发指令到特定的服务器
                        SCMDIN_FORWARD_TO_ANYONE_SERVER_BY_TYPE = 0x0001,	// 转发指令到特定类型的任意一台服务器
                        SCMDIN_FORWARD_TO_ALL_SERVER_BY_TYPE    = 0x0002,	// 转发指令到特定类型的所有服务器
                        SCMDIN_FORWARD_TO_USER                  = 0x0003,
                };
                enum { //CMDIN_FUNC
                        SCMDIN_FUNC_LEAVE_ROOM_old              = 0x0003,	// 用户离开房间
                        SCMDIN_FUNC_LEAVE_ROOM_RES_old          = 0x0004,	// 通知Session有用户离开某房间
                        SCMDIN_FUNC_UPDATE_USER_SESSION         = 0x0005,       // 通知roomserver更新用户当前所在的sessionserver
                        SCMDIN_FUNC_UPDATE_USER_NICKNAME        = 0x0006,       // 通知房间用户有用户的昵称改变了
                        SCMDIN_FUNC_CHECK_USER_SESSION_REQ      = 0x0007,       // 请求核实用户所在Session是否有效
                        SCMDIN_FUNC_CHECK_USER_SESSION_RES      = 0x0008,       // 返回合适用户所在Session结果
                        SCMDIN_FUNC_ENTER_ROOM                  = 0x000A,       // 用户进入房间
                        SCMDIN_FUNC_ENTER_ROOM_RES              = 0x000B,	// 用户进入房间结果
                        SCMDIN_FUNC_LEAVE_ROOM                  = 0x000C,
                        SCMDIN_FUNC_LEAVE_ROOM_RES              = 0x000D,
                        SCMDIN_FUNC_NOTIFY_ROOM_USERSTATUS_CHANGE       = 0x000E,       // 通知用户所在房间 用户的状态改变
                };

                //	cmd definition
                struct stLoginCmd:t_NullCmd
                {
                        stLoginCmd():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN)
                        {
                                server_type_ = 0;
                                server_id_ = 0;
                                dest_type_ = ROOMSERVER;
                        }
                        WORD server_type_;
                        DWORD server_id_;
                        WORD dest_type_;
                };
                struct stLoginResponce:t_NullCmd
                {
                        stLoginResponce():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RESPONCE)
                        {
                        }
                };
                //cmd pkg define
                struct stPkgUserCmd:
                        t_NullCmd
                {
                        stPkgUserCmd():
                                t_NullCmd(CMDIN_PKG, SCMDIN_PKG_USER_CMD)
                        {
                                user_id_ = 0;
                                room_id_ = 0;
                                server_id_ = 0;
                                size_ = 0;
                        }
                        DWORD user_id_;
                        DWORD room_id_;
                        WORD server_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() const
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stPkgInnerCmd:
                        t_NullCmd
                {
                        stPkgInnerCmd():
                                t_NullCmd(CMDIN_PKG, SCMDIN_PKG_INNER_CMD)
                        {
                                server_id_ = 0;
                                size_ = 0;
                        }
                        WORD server_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() const
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stPkgUserCmdBroad:
                        t_NullCmd
                {
                        stPkgUserCmdBroad():
                                t_NullCmd(CMDIN_PKG, SCMDIN_PKG_USER_CMD_BROAD)
                        {
                                room_id_ = 0;
                                except_id_ = 0;
                                size_ = 0;
                        }
                        DWORD room_id_;
                        DWORD except_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() const
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };

                struct stForwardToServerByServerID:
                        t_NullCmd
                {
                        stForwardToServerByServerID():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_SERVER_BY_SERVERID)
                        {
                                server_id_ = 0;
                                size_ = 0;
                        }
                        WORD server_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardToAnyOneServerByType:
                        t_NullCmd
                {
                        stForwardToAnyOneServerByType():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_ANYONE_SERVER_BY_TYPE)
                        {
                                server_type_ = 0;
                                size_ = 0;
                        }
                        WORD server_type_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardToAllServerByType:
                        t_NullCmd
                {
                        stForwardToAllServerByType():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_ALL_SERVER_BY_TYPE)
                        {
                                server_type_ = 0;
                                size_ = 0;
                        }
                        WORD server_type_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardToUser:
                        t_NullCmd
                {
                        stForwardToUser():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_USER)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                size_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stFuncEnterRoom:
                        t_NullCmd
                {
                        stFuncEnterRoom():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_ENTER_ROOM)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                user_type_ = 0;
                                bzero(account_, sizeof(account_));
                                bzero(nick_name_, sizeof(nick_name_));
                                ip_ = 0;
                                mac_ = 0;
                                net_ = 0;
                                terminal_ = eTerminalType_pc;
                                new_ = 0;
                                user_status_ = eUserStatusType_normal;
                        }

                        uint32_t room_id_;
                        uint32_t user_id_;
                        uint8_t user_type_;             // eUserLoginType
                        char account_[MAX_ACCOUNT_SIZE+1];
                        char nick_name_[MAX_NAME_SIZE+1];
                        uint32_t ip_;
                        uint64_t mac_;
                        uint16_t net_;                  // 0-dx 1-wt
                        uint8_t terminal_;              // eTerminalType
                        uint8_t new_;                   // 为做兼容而作
                        uint8_t user_status_;           // eUserStatusType
                        char unique_sid[128];     // unique session id.
                };
                struct stFuncEnterRoomRes:
                        t_NullCmd
                {
                        stFuncEnterRoomRes():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_ENTER_ROOM_RES)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                user_type_ = 0;
                                ret_code_ = eJoinRoomRet_Fail;
                        }
                        
                        uint32_t room_id_;
                        uint32_t user_id_;
                        uint8_t user_type_;             // eUserLoginType
                        uint8_t ret_code_;              // eJoinRoomRet
                };
                struct stFuncLeaveRoom_old:
                        t_NullCmd
                {
                        stFuncLeaveRoom_old():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_LEAVE_ROOM_old)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                };
                struct stFuncLeaveRoomRes_old:
                        t_NullCmd
                {
                        stFuncLeaveRoomRes_old():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_LEAVE_ROOM_RES_old)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                };
                struct stFuncUpdateUserSession:
                        t_NullCmd
                {
                        stFuncUpdateUserSession():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_UPDATE_USER_SESSION)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                session_id_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        WORD session_id_;
                };
                struct stFuncUpdateUserNickName:
                        t_NullCmd
                {
                        stFuncUpdateUserNickName():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_UPDATE_USER_NICKNAME)
                        {
                                room_id_ = 0;
                                user_id_ = 0 ;
                                bzero(nick_name_, sizeof(nick_name_));
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        char nick_name_[MAX_NAME_SIZE+1];
                };
                struct stFuncCheckUserSessionReq:
                        t_NullCmd
                {
                        stFuncCheckUserSessionReq():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_CHECK_USER_SESSION_REQ)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                };
                struct stFuncCheckUserSessionRes:               // 暂时不用
                        t_NullCmd
                {
                        stFuncCheckUserSessionRes():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_CHECK_USER_SESSION_RES)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                ret_code_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        BYTE ret_code_;         // 0表示在，1表示不在但在线，2，不在线
                };
                struct stFuncLeaveRoom:
                        t_NullCmd
                {
                        stFuncLeaveRoom():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_LEAVE_ROOM)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                        }

                        uint32_t room_id_;
                        uint32_t user_id_;
                        uint8_t user_type_;
                };
                struct stFuncLeaveRoomRes:
                        t_NullCmd
                {
                        stFuncLeaveRoomRes():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_LEAVE_ROOM_RES)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                user_type_ = 0;
                        }

                        uint32_t room_id_;
                        uint32_t user_id_;
                        uint8_t user_type_;
                };
                struct stFuncNotifyRoomUserstatusChange:
                        t_NullCmd
                {
                        stFuncNotifyRoomUserstatusChange():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_FUNC_NOTIFY_ROOM_USERSTATUS_CHANGE)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                user_status_ = eUserStatusType_normal;
                        }

                        uint32_t room_id_;
                        uint32_t user_id_;
                        uint8_t user_status_;
                };
        }; //namespace Super
}; //namespace Cmd
#pragma pack() //pack(1)

#endif //SUPER_COMMAND_H_
